//2009/08/02 17:27:30
#include <string>

using namespace std;

class TireRotation
{
public:
    int getCycle(string initial, string current)
    {
        for (int i=1; i<=4; i++)
        {
            if (initial.compare(current) == 0)
                return i;
            initial = rotate(initial);
        }
        return -1;
    }
private:
    string rotate(string ini)
    {
        string s;
        s += ini[3];
        s += ini[2];
        s += ini[0];
        s += ini[1];
        return s;
    }
};
